<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<title>Genera codici per questionario</title>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<link type="text/css" rel="stylesheet" href="../menu.css" />
<?php
	header('Content-type: text/html; charset=utf-8');
	include_once 'header.php';
	include_once '../taglib.php';
	
	$urlxml = "../resources/config.xml";
	$config= new SimpleXmlElement($urlxml,1,true);
	//$config = simplexml_load_file($urlxml); 
	
	$dbname = $config->database->name;
	$user = $config->database->user;
	$pass = $config->database->password;
	
	$factory = new ComboTableFactory($dbname,$user,$pass);
	$enti = $factory->comboTable("enti","codice","concat(codice,' - ',azienda,' - ',ospedale)");
	
	$ente = $_REQUEST['ente'];
	$numero = $_REQUEST['numero'];
	$codex = base_convert($ente,36,10);
	$array = array();
	$count = 0;
	for($i=4;$count<$numero;$i++){
		if($i%36 != 0){
			$var = strtoupper($ente.base_convert($codex*$i,10,36));
			array_push($array, $var);
			$count ++;
		}
	}
?>
</head>
<body>
<h1>Genera Codici per Ente</h1>
<div id="lista">
<table>
	<tr></tr>
</table>
</div>
<div id="box" class="box" style="width: 400px;margin-left: auto;margin-right: auto;">
	<form id="login" action="" method="post">
		<table border="1px" style="font-family: monospace;">
		<tr><td colspan="2"><label>Codice Ente</label>
		<?php new TagCombo($ente , $enti,'ente',true)?>
		</td><td>Numero
		<input type="text" name="numero" id="numero" maxlength="2" style="width: 20px;" value="20" />
		</td><td><input type="submit" id="azione" name="azione" value="genera"  /></td>
		</tr>
		<?php for ($i=0;$i < count($array);$i++) { ?>	
		<tr>
		<td width="20px"><?php print $i+1 ?></td>
		<td><?php print $array[$i]?></td>
		</tr>
		<?php }?>
		</table>
		<input type="hidden" id="azione" name="azione" value="genera" />
		<input type="hidden" id="codice" name="codice" value="" />
	</form>
	<p><a href="menu.html">ritorna al Menù amministrazione</a></p>
</div>
</body>
</html>